<?php
  session_start();
  function validerLogin(){
    if (isset($_POST["utilisateur"] ) && $_POST["utilisateur"] == "admin"){
     if (isset($_POST["mdp"] ) && $_POST["mdp"] == "passe")
       $_SESSION["userid"] = 1;
    }
    
    if (!isset($_SESSION["userid"])){
     echo "<html>
  <head>
    <link type='text/css' rel='stylesheet' href='../style/admin.css' />
  </head>
  <body>
      <div id='banniere'>&nbsp;</div>
      <form method='POST' action='index.php'>
         <table><tr><td>
         Nom d'utilisateur:</td><td><input type='text' name='utilisateur' class='login' />
         </td></tr><tr><td>
         Mot de passe: </td><td><input type='password' name='mdp' class='login' />
         </td></tr><tr><td colspan='2'>
         <input type='submit' value='valider' class='login' />
         </td></tr></table>
       </form>
   </body>
</html>";
     die();
    }
      
  }
    /**
   * V�rifie si la date entr�e dans le formulaire est du
   * format attendu
   *
   * @param String $pDate
   * @return boolean
   */
  function isDateValide($pDate){
    $parties = explode('/',$pDate);
    if ((int)$parties[0] > 0 && (int)$parties[0] <= 31 &&
      (int)$parties[1] > 0 && (int)$parties[1] <= 12 &&
      strlen($parties[2]) == 4)
      return true;
    else 
      return false;
  }
  
  function convertToTimestamp($pDate){
    $parties = explode('/',$pDate);
    return mktime(0,0,0,$parties[1],$parties[0],$parties[2]);
  }
  function convertToDate($pDate){
    return Date("d/m/Y",$pDate);
  }
  
  function convertToArray($pDate){
    
    return array (  "jour" => Date("d",$pDate),
            "mois" => Date("m",$pDate),
            "annee" => Date("Y",$pDate));
  }  
  function getEtiquetteType($no){
    switch($no){
      case 1:
        return "Texte simple";
      break;
      case 2:
        return "Texte libre";
      break;
      case 3:
        return "Liste des membres";
      break;
      case 4:
        return "Date";
      break;
      case 5:
        return "Jour de participation";
      break;
      case 6:
        return "Boite d&eacute;roulante";
      break;
      case 7:
        return "Liste";
      break;
      case 8:
        return "Cases &agrave; cocher";
      break;
      default:
        return "%Type inexistant%";
    }
  }
  
  function clean_for_db($value){

   $value = trim($value);
   if(get_magic_quotes_gpc()){
      $value = stripslashes($value);
   }
   if(!is_numeric($value)){
   
      $text = mysql_real_escape_string($value);
      if($text === FALSE){  // we must not be connected to mysql, so....
         $text = mysql_escape_string($value);
      }
      $value = "'$text'";
   }
   return($value);
  }
  function clean_for_display(){
    
  }
  function clean_for_(){
  
  }
?>